package com.gene.service.impl;

import com.gene.mapper.UserReportMapper;
import com.gene.pojo.UserReport;
import com.gene.pojo.UserReportExample;
import com.gene.service.IUserReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserReportServiceImpl implements IUserReportService {
    @Autowired
    private UserReportMapper userReportMapper;

    @Override
    public List<UserReport> query(UserReport userReport) {
        UserReportExample example=new UserReportExample();
        UserReportExample.Criteria criteria=example.createCriteria();
        criteria.andUserIdEqualTo(userReport.getUserId());
        example.setOrderByClause("ctime desc");
        List<UserReport> list = userReportMapper.selectByExample(example);
        return list;
    }

    @Override
    public UserReport selectId(UserReport userReport) {
        UserReport userReport1=userReportMapper.selectByPrimaryKey(userReport.getReportId());
        return userReport1;
    }

    @Override
    public boolean add(UserReport userReport) {
        userReport.setCtime(new Date());
        int a=userReportMapper.insert(userReport);
        if(a ==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean edit(UserReport userReport) {
        int a=userReportMapper.updateByPrimaryKeySelective(userReport);
        if(a ==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(UserReport userReport) {
        int a=userReportMapper.deleteByPrimaryKey(userReport.getReportId());
        if(a ==1){
            return true;
        }
        return false;
    }
}
